luci-app-attendedsysupgrade: fix empty array condition
authorPaul Spooren <[email protected]>
Sun, 25 Jul 2021 22:36:19 +0000 (00:36 +0200)
committerPaul Spooren <[email protected]>
Mon, 26 Jul 2021 12:02:22 +0000 (14:02 +0200)
In JavaScript (other than in Python) an empty array is considered `true`
within if statements. Fix this by checking for the array length rather
than its existence.

This fixes the issue of an empty dropdown menu in case the user is
running the latest release.

Signed-off-by: Paul Spooren <[email protected]>
(cherry picked from commit 7f5becc69e004f831c9dc09e0859c179b439c7d2)

applications/luci-app-attendedsysupgrade/htdocs/luci-static/resources/view/attendedsysupgrade/overview.js

index f6d31a35beb7c1146b96f35d08f14d586d036d34..3ee99684da11f3ee34632c7619c81e6092ed2a3e 100644 (file)
@@ -255,7 +255,7 @@ function check_sysupgrade(server_url, current_version, target, board_name, packa
                                        }
                                }
                        }
-                       if (candidates) {
+                       if (candidates.length) {
                                var m, s, o;
 
                                var mapdata = {